﻿using Kugar.Web.Wechat.Enums;
using Kugar.Web.Wechat.Serializers;
using Newtonsoft.Json;

namespace Kugar.Web.Wechat.Entities
{
    [JsonConverter(typeof(WxMessageNewtonsoftJsonSerializer))]
    public abstract class WxMessageBase
    {
        public string ToUserOpenID { set; get; }

        public abstract WxMessageMsgTypeEnum MsgType {get; }
    }

    [JsonConverter(typeof(WxMessageNewtonsoftJsonSerializer))]
    public class WxMessage_Text : WxMessageBase
    {
        public string Text { set; get; }

        public override WxMessageMsgTypeEnum MsgType { get; }= WxMessageMsgTypeEnum.Text;
    }

    [JsonConverter(typeof(WxMessageNewtonsoftJsonSerializer))]
    public class WxMessage_Image : WxMessageBase
    {
        public string MediaID { set; get; }
        public override WxMessageMsgTypeEnum MsgType { get; }= WxMessageMsgTypeEnum.Image;
    }


    [JsonConverter(typeof(WxMessageNewtonsoftJsonSerializer))]
    public class WxMessage_Voice : WxMessageBase
    {
        public string MediaID { set; get; }

        public override WxMessageMsgTypeEnum MsgType { get; } = WxMessageMsgTypeEnum.Voice;
    }

    [JsonConverter(typeof(WxMessageNewtonsoftJsonSerializer))]
    public class WxMessage_Video : WxMessageBase
    {
        public string MediaID { set; get; }

        public string Thumb_media_id { set; get; }

        public string Title { set; get; }

        public string Description { set; get; }

        public override WxMessageMsgTypeEnum MsgType { get; } = WxMessageMsgTypeEnum.Video;

        
    }

    [JsonConverter(typeof(WxMessageNewtonsoftJsonSerializer))]
    public class WxMessage_News : WxMessageBase
    {
        public override WxMessageMsgTypeEnum MsgType { get; }= WxMessageMsgTypeEnum.News;

        public NewsItem[] Articles { set; get; }

        public class NewsItem
        {
            public string Title { set;get; }

            public string Description { set; get; }

            public string Url { set;get; }

            public string PicUrl { set;get; }
        }
    }
}
